﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeneticAlgorithm.Demo.Common.Function
{
    [AttributeUsage(AttributeTargets.Class)]
    public class DisplayTextAttribute : Attribute
    {
        public static readonly DisplayTextAttribute Default = new DisplayTextAttribute();

        public string DisplayText { get; private set; }
        public FunctionType Function { get; private set; }

        public DisplayTextAttribute()
            : this(FunctionType.UnaryFunction1, string.Empty)
        {
        }

        public DisplayTextAttribute(FunctionType functionType, string text)
        {
            this.Function = functionType;
            DisplayText = text;
        }

        public override bool Equals(object obj)
        {
            DisplayTextAttribute? displayTextAttribute = obj as DisplayTextAttribute;
            if (displayTextAttribute != null)
            {
                return DisplayText.Equals(displayTextAttribute.DisplayText);
            }

            return false;
        }

        public override int GetHashCode()
        {
            return DisplayText.GetHashCode() | Function.GetHashCode();
        }

        public override bool IsDefaultAttribute()
        {
            return Equals(Default);
        }
    }
}
